﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Shell;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace HangedManConsulting.PomodoroTimerforVS
{

    [ClassInterface(ClassInterfaceType.AutoDual)]
    [CLSCompliant(false), ComVisible(true)]
    public class PomodoroTimerOptions:DialogPage
    {

        private const int POMODORO_LENGTH = 25;
        private const int SHORT_BREAK_LENGTH = 5;
        private const int LONG_BREAK_LENGTH = 15;
        private const int POMODOROS_PER_CYCLE = 4;
        private const bool PLAY_AUDIO_FEEDBACK_FOR_TIMER_END = true;
        private const bool FLASH_TASKBARICON_FOR_TIMER_END = true;


        private int? _PomodoroLength;
        [Category("Pomodoro Timing")]
        [DisplayName("Pomodoro Length")]
        [Description("Length of a pomodoro")]
        public int? PomodoroLength
        {
            get
            {
                if (_PomodoroLength == null) {
                    return POMODORO_LENGTH;
                } else {
                    return _PomodoroLength;
                }
            }
            set
            {
                _PomodoroLength = value;
            }
        }

        private int? _ShortBreakLength;
        [Category("Pomodoro Timing")]
        [DisplayName("Short Break Length")]
        [Description("Length of a short break between pomodoros")]
        public int? ShortBreakLength
        {
            get
            {
                if (_ShortBreakLength == null) {
                    return SHORT_BREAK_LENGTH;
                } else {
                    return _ShortBreakLength;
                }
            }
            set
            {
                _ShortBreakLength = value;
            }
        }
        private int? _LongBreakLength;
        [Category("Pomodoro Timing")]
        [DisplayName("Long Break Length")]
        [Description("Length of a break between pomodoro cycles")]
        public int? LongBreakLength
        {
            get
            {
                if (_LongBreakLength == null) {
                    return LONG_BREAK_LENGTH;
                } else {
                    return _LongBreakLength;
                }
            }
            set
            {
                _LongBreakLength = value;
            }
        }
        private int? _PomodorosPerCycle;
        [Category("Pomodoro Timing")]
        [DisplayName("Pomodoros Per Cycle")]
        [Description("Number of pomodoros between long breaks")]
        public int? PomodorosPerCycle
        {
            get
            {
                if (_PomodorosPerCycle == null) {
                    return POMODOROS_PER_CYCLE;
                } else {
                    return _PomodorosPerCycle;
                }
            }
            set
            {
                _PomodorosPerCycle = value;
            }
        }

        private bool? _PlayAudioFeedbackForTimerEnd;
        [Category("Notifications")]
        [DisplayName("Play audio feedback")]
        [Description("Play a ringing sound when a pomodoro or break is over")]
        public bool? PlayAudioFeedbackForTimerEnd
        {
            get
            {
                if (_PlayAudioFeedbackForTimerEnd == null) {
                    return PLAY_AUDIO_FEEDBACK_FOR_TIMER_END;
                } else {
                    return _PlayAudioFeedbackForTimerEnd;
                }
            }
            set
            {
                _PlayAudioFeedbackForTimerEnd = value;
            }
        }

        private bool? _FlashTaskbarIconForTimerEnd;
        [Category("Notifications")]
        [DisplayName("Flash Visual Studio taskbar icon")]
        [Description("Flash the host Visual Studio taskbar icon when a pomodoro or break is over")]
        public bool? FlashTaskbarIconForTimerEnd
        {
            get
            {
                if (_FlashTaskbarIconForTimerEnd == null) {
                    return FLASH_TASKBARICON_FOR_TIMER_END;
                } else {
                    return _FlashTaskbarIconForTimerEnd;
                }
            }
            set
            {
                _FlashTaskbarIconForTimerEnd = value;
            }
        }

        protected override void OnApply(PageApplyEventArgs e)
        {
            base.OnApply(e);
            PomodoroTimerforVSPackage.PomodoroLength = (int)_PomodoroLength;
            PomodoroTimerforVSPackage.ShortBreakLength = (int)_ShortBreakLength;
            PomodoroTimerforVSPackage.LongBreakLength = (int)_LongBreakLength;
            PomodoroTimerforVSPackage.PomodorosPerCycle = (int)_PomodorosPerCycle;
            PomodoroTimerforVSPackage.PlayAudioFeedbackForTimerEnd = (bool)_PlayAudioFeedbackForTimerEnd;
            PomodoroTimerforVSPackage.FlashTaskbarIconForTimerEnd = (bool)_FlashTaskbarIconForTimerEnd;
            
        }


        //future use
        //public bool FlashTimerOnPomodoroCompletion { get; set; }

    }

}
